package com.xfatm.util.string;

import java.util.Arrays;
import java.util.List;

public class StringUtils {

    /**
     * 列表组合成字符串
     * @param list 列表
     * @param splitString 分割字符串
     * @param itemWarpString 包裹项目的字符串
     * @return 结果
     */
    public static String list2String(List<? extends Object> list,String splitString,String itemWarpString){
        StringBuffer sb=new StringBuffer();
        for(Object o:list){
            sb.append(splitString)
                    .append(itemWarpString)
                    .append(o)
                    .append(itemWarpString);
        }
        if(sb.length()>0){
            return sb.substring(splitString.length());
        }
        return sb.toString();
    }

    public static String list2String(List<? extends Object> list,String splitString){
        return list2String(list,splitString,"");
    }

    public static String array2String(Object[] arrs,String splitString,String itemWarpString){
        return list2String(Arrays.asList(arrs),splitString,itemWarpString);
    }

    public static String array2String(Object[] arrs,String splitString){
        return list2String(Arrays.asList(arrs),splitString,"");
    }

    public static String getMethodName(String fieldName,String head){
        return head+fieldName.substring(0,1)+fieldName.substring(1);
    }

    public static boolean isBlank(String str){
        return str==null||str.trim().length()==0;
    }
}
